<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>循环</title>
    <script src="js/vue.js"></script>
</head>
<body>
    <div id="demo">
        <ol>
            <li v-for="(todo, index) in todos" :key="index">
                {{todo.text}}-----{{index}}---
                <button @click="deleteP(index)">删除</button> ----
                <button @click="updateP(index,'hello')">更新</button>
                <a :title="todo.text">绑定</a>
            </li>
        </ol>
    </div>
<script>
    let app = new Vue({
        el: '#demo',
        data:{
            todos: [
                { text: '学习 JavaScript' },
                { text: '学习 Vue' },
                { text: '整个牛项目'}
            ]
        },
        methods:{
            deleteP(index){
                this.todos.splice(index, 1);
            },
            updateP(index, text){
                this.todos[index].text = text;
            }
        }
    });

    app.todos.push({text: '新项目'});
</script>
</body>
</html>